using System.Threading.Tasks;
using JGSY.CourseManagement.Domain.Entities;

namespace JGSY.CourseManagement.Domain.Interfaces
{
    /// <summary>
    /// 用户仓储接口，定义用户数据操作
    /// </summary>
    public interface IUserRepository
    {
        /// <summary>
        /// 根据用户名获取用户
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <returns>用户实体或null</returns>
        Task<User> GetByUserNameAsync(string userName);

        /// <summary>
        /// 添加新用户
        /// </summary>
        /// <param name="user">用户实体</param>
        Task AddAsync(User user);

        /// <summary>
        /// 更新用户信息
        /// </summary>
        /// <param name="user">用户实体</param>
        Task UpdateAsync(User user);

        /// <summary>
        /// 检查用户名是否已存在
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <returns>存在返回true，否则返回false</returns>
        Task<bool> ExistsByUserNameAsync(string userName);
    }
}